//
//  BSActivityCollectionViewCell.m
//  BS
//
//  Created by 王浩宇 on 15/8/21.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "BSActivityCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation BSActivityCollectionViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setModel:(BSActivityModel *)model
{
    _model = model;
    [_imageList sd_setImageWithURL:[NSURL URLWithString:model.image_list]];
    _nameLabel.text = model.theme_name;
    //获取当前时间
    NSDate *  senddate=[NSDate date];
    //把字符串时间转为NSDate
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:8]];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:"];
    NSDate *endTime = [formatter dateFromString:model.end_time];
    //跟1970时间差
    NSTimeInterval fitstDate = [senddate timeIntervalSince1970]*1;
    NSTimeInterval secondDate = [endTime timeIntervalSince1970]*1;
    NSLog(@"fitst:%f",fitstDate);
    NSLog(@"second:%f",secondDate);
//比较时间差
    if (secondDate > fitstDate) {
        _totalLabel.text = [NSString stringWithFormat:@"进行中(%@人参与)",model.total_users];
    }else if (secondDate < fitstDate){
        _totalLabel.text = [NSString stringWithFormat:@"已结束(%@人参与)",model.total_users];
    }

}

@end
